package org.example;

import org.example.config.AppConfig;
import org.example.task.ScheduledTask;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 初始化Spring上下文
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        System.out.println("应用启动成功!");

        // 获取定时任务Bean并启动倒计时任务
        ScheduledTask scheduledTask = context.getBean(ScheduledTask.class);
        scheduledTask.startCountdownTask();

        // 保持应用运行
        try {
            Thread.currentThread().join();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
}
